package com.example.controller;

import com.example.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/area")
public class AreaController {
    @Autowired
    private AreaService areaService;

    /**
     * 缩减普通的宿舍名称
     * @return 字符串提示信息
     */
    @PutMapping("/dormitory/reduce")
    public String reduceDormitoryAreaName(){
        int i = areaService.reduceDormitoryAreaName();
        return "成功（缩减了"+i+"条数据）";
    }

    /**
     * 缩减带有校区的宿舍名称
     * @param campusSuffixName
     * @return 字符串提示信息
     */
    @PutMapping("/dormitory/reduceByCampus")
    public String reduceDormitoryAreaNameByCampus(String campusSuffixName){
        int i = areaService.reduceDormitoryAreaNameByCampus(campusSuffixName);
        return "成功（缩减了"+i+"条数据）";
    }

    /**
     * 更新分校区简称
     * @param originalPath
     * @return 字符串提示信息
     */
    @PutMapping("/campus/areaAbbreviated")
    public String updateBranchCampusAreaAbbreviated(String originalPath){
        return areaService.updateBranchCampusAreaAbbreviated(originalPath);
    }

    /**
     * 为四级地址填充父id
     */
    @GetMapping("/fill/parentId")
    public String fillParentId(String originalPath){
        return areaService.fillParentId(originalPath);
    }

    /**
     * 增加四级地址库没有的书店地址
     */
    @PostMapping("/add/bookstoreArea")
    public String addBookstoreArea(String originalPath,String bookstoreAreaPath){
        return areaService.addBookstoreArea(originalPath,bookstoreAreaPath);
    }

    /**
     * 查找出四级地址库中没有的书店地址
     */
    @GetMapping("/find/no/bookstoreArea")
    public String findNoBookstoreArea(String areaPath,String bookstoreAreaPath){
        return areaService.findNoBookstoreArea(areaPath,bookstoreAreaPath);
    }

    /**
     * 将五级地址的父id改为新增的四级id
     */
    @GetMapping("/fifthArea/fill/parentId")
    public String fifthAreaFillParentId(String originalPath,String earlyVillagePath,String fourLevelDBPath,String fiveLevelPath){
        return areaService.fifthAreaFillParentId(originalPath,earlyVillagePath,fourLevelDBPath,fiveLevelPath);
    }

    /**
     * 将五级地址的父id改为新增的四级id（包含匹配）
     */
    @GetMapping("/fifthAreaContains/fill/parentId")
    public String fifthAreaContainsFillParentId(String originalPath,String earlyVillagePath,String fourLevelDBPath,String fiveLevelPath){
        return areaService.fifthAreaContainsFillParentId(originalPath,earlyVillagePath,fourLevelDBPath,fiveLevelPath);
    }

    /**
     * 将五级地址的父id改为新增的四级id（不匹配街道）
     */
    @GetMapping("/fifthAreaNoStreet/fill/parentId")
    public String fifthAreaNoStreetFillParentId(String originalPath,String earlyVillagePath,String fourLevelDBPath,String fiveLevelPath){
        return areaService.fifthAreaNoStreetFillParentId(originalPath,earlyVillagePath,fourLevelDBPath,fiveLevelPath);
    }

    /**
     * 将校区宿舍改成某某校区，无校区用1-20宿舍楼（第一种方案）
     */
    @PutMapping("/dormitory/modify1")
    public String modifyDormitory1(String schoolPath,String teacherPath){
        return areaService.modifyDormitory1(schoolPath,teacherPath);
    }

    /**
     * 将合并了校区的宿舍改成某某校区
     */
    @PutMapping("/dormitory/modify")
    public String modifyDormitory(String schoolPath){
        return areaService.modifyDormitory(schoolPath);
    }

    /**
     * 高德抓的数据填充四级地址id
     */
    @PutMapping("/gaodeData/fill/areaId")
    public String gaodeDataFillAreaId(String originalPath){
        return areaService.gaodeDataFillAreaId(originalPath);
    }

    /**
     * 根据经纬度填充四级地址id
     */
    @PutMapping("/latLon/fill/areaId")
    public String latitudeLongitudeFillAreaId(String originalPath,String areaPath){
        return areaService.latitudeLongitudeFillAreaId(originalPath,areaPath);
    }

    /**
     * 去掉街道下同名的幼儿园
     */
    @PutMapping("/street/kindergartenSame")
    public String removeStreetKindergartenSame(String originalPath){
        return areaService.removeStreetKindergartenSame(originalPath);
    }

    /**
     * 为小组创建组长（没手机号的先空着）
     */
    @PutMapping("/fill/groupLeader")
    public String fillGroupLeader(String originalPath){
        return areaService.fillGroupLeader(originalPath);
    }

    /**
     * 根据经纬度填充五级地址id
     */
    @PutMapping("/latLon/fill/communityId")
    public String latitudeLongitudeFillCommunityId(String poiPath,String areaPath){
        return areaService.latitudeLongitudeFillCommunityId(poiPath,areaPath);
    }

    /**
     * 根据经纬度算出离大学（小学）近的书店，大学1公里，小学也1公里
     */
    @GetMapping("/calculate/bookstore")
    public String calculateBookstore(String poiPath,String areaPath){
        return areaService.calculateBookstore(poiPath,areaPath);
    }

    /**
     * 大学书店填充大学id，宿舍id（areaId，villageId）
     */
    @PutMapping("/fill/universityArea")
    public String fillUniversityArea(String poiPath,String areaPath){
        return areaService.fillUniversityArea(poiPath,areaPath);
    }

    /**
     * 更新地址经纬度，通过villageId
     */
    @PutMapping("/update/lonLatByVillageId")
    public String updateLonLatByVillageId(String originalPath){
        return areaService.updateLonLatByVillageId(originalPath);
    }

    /**
     * 更新地址经纬度，通过communityId
     */
    @PutMapping("/update/lonLatByCommunityId")
    public String updateLonLatByCommunityId(String originalPath){
        return areaService.updateLonLatByCommunityId(originalPath);
    }

    /**
     * 更新大学宿舍经纬度（宿舍先用大学的经纬度）
     */
    @PutMapping("/update/lonLat/dormitory")
    public String updateLonLatDormitory(String schoolPath,String mergeCampusPath){
        return areaService.updateLonLatDormitory(schoolPath,mergeCampusPath);
    }

    /**
     * 合并城区   t_area_contact要取消联合主键，要不然会出错
     */
    @PutMapping("/merger/district")
    public String mergerDistrict(String originalPath){
        return areaService.mergerDistrict(originalPath);
    }

    /**
     * 直辖市 合并合并过城区的高校的二级地址（将直辖市合并过城区的高校放在一起）
     */
    @PutMapping("/merger/city/zhixiashiUniversity")
    public String mergerCityOfZhixiashiUniversity(String originalPath){
        return areaService.mergerCityOfZhixiashiUniversity(originalPath);
    }

}
